<template>
  <el-dialog title="参数编辑" width="500px" v-model="dialogFormVisible">
    <el-form :model="form" size="small">
      <el-form-item label="参数名称" :label-width="formLabelWidth">
        <el-input v-model="form.key_set_name" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="参数KEY名" :label-width="formLabelWidth">
        <el-input v-model="form.key_set_key" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="参数单位" :label-width="formLabelWidth">
        <el-input v-model="form.key_set_unit" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="默认值" :label-width="formLabelWidth">
        <el-input v-model="form.key_set_default" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="小数保留位数" :label-width="formLabelWidth">
        <el-input v-model="form.tofixed" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="排序" :label-width="formLabelWidth">
        <el-input v-model="form.sort_no" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="描述" :label-width="formLabelWidth">
        <el-input
          type="textarea"
          v-model="form.key_set_describe"
          autocomplete="off"
        ></el-input>
      </el-form-item>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button size="small" @click="cancelFunc()">取 消</el-button>
        <el-button size="small" type="primary" @click="confirmFunc()"
          >确 定</el-button
        >
      </span>
    </template>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      //是否显示
      dialogFormVisible: false,
      //表单数据
      form: {
        //默认值
        key_set_default: 0,
        //参数描述
        key_set_describe: "",
        //参数KEY名
        key_set_key: "",
        //参数名称
        key_set_name: "",
        //参数类别
        key_set_type: "",
        //参数单位
        key_set_unit: "",
        //参数状态
        status: 1,
        //小数保留位数
        tofixed: 0,
        //排序
        sort_no: 100,
      },
      //左边标签宽度
      formLabelWidth: "120px",
    };
  },
  props: {
    visible: Boolean,
  },
  watch: {
    //监听是否显示
    visible(newVal, oldVal) {
      if (newVal != oldVal) {
        this.dialogFormVisible = newVal;
      }
    },
  },
  created() {},
  methods: {
    /**
     * 确认
     */
    confirmFunc() {
      this.$message({
        type: "success",
        message: "操作成功!",
      });
      this.cancelFunc();
    },

    /**
     * 取消
     */
    cancelFunc() {
      this.$emit("close", false);
    },
  },
};
</script>

<style lang="scss">
</style>